package com.grts.mall.common;

public class CommonResult {
	private int code;
	private String msg;
	private Object data;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public CommonResult() {
	}

	public CommonResult(int code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static CommonResult success() {
		return success("SUCCESS");
	}

	public static CommonResult success(String msg) {
		return success(0, msg);
	}

	public static CommonResult success(int code, String msg) {
		return build(code, msg, null);
	}
	
	public static CommonResult success(Object data) {
		return build(0, "SUCCESS", data);
	}
	
	public static CommonResult success(String msg, Object data) {
		return build(0, msg, data);
	}

	public static CommonResult error() {
		return error("ERROR");
	}

	public static CommonResult error(String msg) {
		return error(1, msg);
	}

	public static CommonResult error(int code, String msg) {
		return build(code, msg, null);
	}

	public static CommonResult build(int code, String msg, Object data) {
		return new CommonResult(code, msg, data);
	}

	

}